package org.easy.eao.spring.hibernate;

import java.util.Set;

import org.easy.eao.annotations.Named;
import org.easy.eao.annotations.Paging;
import org.easy.eao.annotations.Query;
import org.easy.eao.annotations.Paging.Number;
import org.easy.eao.annotations.Paging.Size;
import org.easy.eao.spring.hibernate.model.Exam;
import org.easy.eao.support.Page;

public interface PagingEao {

	@Paging(
		query = @Query(query = "from Exam e where e.student = ? order by e.grade"),
		count = @Query(query = "select count(*) from Exam e where e.student = ? order by e.grade"))
	Page<Exam> hql(String student, @Number Integer page, @Size Integer size);

	@Paging(
		query = @Query(query = "from Exam e where e.student = ? order by e.grade"))
	Page<Exam> hql_without_count(String student, @Number Integer page, @Size Integer size);

	@Paging(
		query = @Query(named = "Exam.findByStudent"),
		count = @Query(named = "Exam.findByStudent[count]"))
	Page<Exam> named(String student, @Number Integer page, @Size Integer size);

	@Paging(
		query = @Query(named = "Exam.findByStudent"))
	Page<Exam> named_without_count(String student, @Number Integer page, @Size Integer size);

	@Paging(
		query = @Query(query = "from Exam e where e.student = :student and e.subject in (:subjects)"))
	Page<Exam> hql_named_para(@Named("student") String student, @Named("subjects")Set<String> subjects, @Size Integer size, @Number Integer page);

	@Paging(size = 3,
		query = @Query(query = "from Exam e order by e.grade"))
	Page<Exam> default_size(@Number Integer page);

	@Paging(page = 1,
			query = @Query(query = "from Exam e order by e.grade"))
	Page<Exam> default_page(@Size Integer size);

	@Paging(page = 1, size = 3,
			query = @Query(query = "from Exam e order by e.grade"))
	Page<Exam> default_page_size();

	@Paging(page = 4, size = 2,
		query = @Query(named = "Exam.all"))
	Page<Exam> overwirte_default(@Number Integer page, @Size Integer size);
}
